package com.freeseed.Controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.freeseed.model.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.naming.AuthenticationException;

@Slf4j
@RestController
@RequestMapping("login")
public class LoginController extends ApiController {
    @Autowired
    private IUserService userService;
    @PostMapping
    public R userLogin(String username , String password){
        String email = username;
        try{
            log.info("email: {} | password: {}",email,password);
            return success(userService.checkLogin(email,password));
        }catch (Exception e){
            return failed(e.getMessage());
        }
    }

}
